<?php

namespace App\Http\Controllers\admin;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;
use Hash;

class CollectController extends Controller
{
    /**
     *收藏列表页
     *
     *@return datas
     */
    
    public function getIndex(Request $request)
    {	
    	//获取id
    	$id = $request -> input('id');
    	
    	//取出数据
    	$datas = DB::table('collect')->where('uid',$id)->get();
    		
    	//把数据分配到页面
    	return view('admin.user.collect',['datas'=>$datas]);
    }

    /**
     *文章表
     *
     *@return res
     */

    public function getList(Request $request)
    {
    	//获取id
    	$id = $request->input('id');
    	
    	//取出数据库的数据
    	// DB::connection()->enableQueryLog();
		$res = DB::table('collectcontentwz')
    		->join('article','collectcontentwz.uid','=','article.uid')
    		->select('article.*')
    		->where('collectcontentwz.cid',$id)
    		->get();
    	// $queries = DB::getQueryLog();
    	// dd($res);
    	
		return view('admin.collect.wz',['res'=>$res]);
    }

    /**
     *文章详情表
     *
     *@return res
     */

    public function getWz(Request $request)
    {	
    	//获取文章标题
    	$title = $request->input('title');
    	//匹配数据库
    	$res = DB::table('article')->where('title',$title)->get();
    	
    	//分配数据
    	return view('admin.collect.wzxq',['res'=>$res]);
    }

    
    /**
     *文章专栏表
     *
     *@return zlwzs
     */

    public function getZlwz(Request $request)
    {
    	//获取id
    	$id = $request->input('id');
    	// dd($id);
    	//查询数据库数据
    	$zlwzs = DB::table('columnarticle')
    		->join('collectcontentzlwz','columnarticle.uid','=','collectcontentzlwz.uid')
    		->select('columnarticle.*')
    		->where('columnarticle.uid',$id)
    		->get();
    	// dd($zlwzs);
    	return view('admin.collect.zlwz',['zlwzs'=>$zlwzs]);
    }

    /**
     *文章专栏详情
     *
     *@return res
     */

    public function getZlwzxq(Request $request)
    {
    	//获取标题
    	$ctitle = $request->input('ctitle');

    	//匹配数据
    	$res = DB::table('columnarticle')->where('ctitle',$ctitle)->get();

    	//分配数据
    	return view('admin.collect.zlwzxq',['res'=>$res]);
    }

    /**
     *答案表
     *
     *@return das
     */

    public function getDa(Request $request)
    {	
    	//获取id
    	$id = $request->input('id');
    	//关联查询数据
    	$das = DB::table('collectcontentda')
    		->join('answer','collectcontentda.aid','=','answer.id')
    		->select('answer.*')
    		->where('collectcontentda.cid',$id)
    		->get();
    	// dd($das);
    	//分配数据
    	return view('admin.collect.da',['das'=>$das]);
    }

    /**
     *专栏表
     *
     *@return res
     */

    public function getZl(Request $request)
    {   
        //获取id
        $id = $request->input('id');
        
        //匹配数据
        $res = DB::table('userdetails')
            ->join('column','userdetails.uid','=','column.uid')
            ->select('column.*')
            ->where('userdetails.uid',$id)
            ->get();

        //分配数据
        return view('admin.collect.zl',['res'=>$res]);
    }

    /**
     *专栏内容表
     *
     *@return res
     */

    public function getZlb(Request $request)
    {   
        //获取id
        $id = $request->input('id');

        //匹配数据
        $res = DB::table('column')->where('id',$id)->get();

        //分配数据
        return view('admin.collect.zlb',['res'=>$res]);
    }

}
